package com.webex.ta.hydra.gui.action;

import com.webex.ta.hydra.core.Command;
import com.webex.ta.hydra.gui.GuiPackage;
import com.webex.ta.hydra.gui.table.HydraTableModel;

import java.awt.event.ActionEvent;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: vegaz
 * Date: 2010-8-31
 * Time: 16:30:30
 * To change this template use File | Settings | File Templates.
 */
public class RemoveAction implements ActionHandler {
    private static Set<String> commands = new HashSet<String>();
	static {
        commands.add(ActionNames.REMOVE);
	}

    public void doAction(ActionEvent e) {
        GuiPackage gp = GuiPackage.getInstance();
        HydraTableModel model = gp.getHydraTable().getModel();

        int[] selected = gp.getHydraTable().getSelectedRows();
        for (int i = selected.length - 1; i >=0; i--) {
            Command cmd = model.getCommandAt(selected[i]);
            model.removeCommand(cmd);
        }
        model.fireTableDataChanged();
    }

    public Set<String> getActionNames() {
        return commands;
    }


}
